﻿layui.use(['layer', 'form'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;

    /* 表单提交 */
    form.on('submit(login)', function (data) {
        var fieldData = data.field;
        fieldData["PostType"] = "login";
        var index = layer.load(2);
        app.ajax("LoginHandle.ashx", fieldData, function (data) {
            layer.close(index);
            if (data.success) {
                layer.msg('登录成功', { icon: 1, time: 1500 }, function () {
                    location.replace('/Business/Index/Index.aspx');
                });
            } else {
                layer.msg(data.msg, { icon: 2, anim: 6 });
            }
        }, function (err) {
            layer.close(index);
            layer.msg('请求失败');
        });
        return false;
    });

    /* 图形验证码 */
    var captchaUrl = 'VerificationCode.aspx';
    $('img.login-captcha').click(function () {
        this.src = captchaUrl + '?t=' + (new Date).getTime();
    }).trigger('click');

});